import { Component, OnInit } from '@angular/core';
import {Rawbeaninventorychange} from '../../../../model/inventory/Rawbeaninventorychange';
import {AlertService} from '../../../../services/alert.service';
import {AdminService} from '../../../../services/admin.service';
import {Materiainventorychange} from "../../../../model/inventory/Materiainventorychange";

@Component({
  selector: 'app-inoutdetaillist',
  templateUrl: './inoutdetaillist.component.html',
  styleUrls: ['./inoutdetaillist.component.css']
})
export class InoutdetaillistComponent implements OnInit {
  cl:Array<Rawbeaninventorychange>;
  ml:Array<Materiainventorychange>
  constructor(private alertservice:AlertService
  ,private adminservice:AdminService) {
    this.cl=new Array<Rawbeaninventorychange>();
    this.ml=new Array<Materiainventorychange>();
  }

  ngOnInit(): void {
    this.loadRawInventoryChangeList();
    this.loadMateriaInventoryChangeList();
  }


  loadRawInventoryChangeList(){
    this.adminservice.getRawBeanInventoryChangeList()
      .then((data:any)=>{
        if(data.msg=='ok'){
          this.cl=new Array<Rawbeaninventorychange>();
          this.cl=data.list;
        }
        else if(data.msg=='empty'){
          this.cl=new Array<Rawbeaninventorychange>();
        }
        else {
          this.alertservice.showError('获取咖啡生豆出入库记录失败');
        }
      })
  }
  loadMateriaInventoryChangeList(){
    this.adminservice.getMateriaInventoryChangeList().then((data:any)=>{
      if(data.msg == "ok"){
        this.ml = data.list
      }
      else if(data.msg=='empty'){
        this.ml=new Array<Materiainventorychange>();
      }else{
        this.alertservice.showError("获取包材出入库数据失败")
      }
    })
  }

}
